package com.gs.djys.checkfragments.approval;

import android.content.Context;

import com.alibaba.fastjson.JSON;
import com.gs.djys.Base.Urls;
import com.gs.djys.checkfragments.license.RouterBean;
import com.gs.djys.mvp.BasePresenterImpl;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;

import java.util.List;

/**
 * MVPPlugin
 *  邮箱 784787081@qq.com
 */

public class ApprovalPresenter extends BasePresenterImpl<ApprovalContract.View> implements ApprovalContract.Presenter{
    @Override
    public void getLink(String req_no) {
        OkGo.<String>get(Urls.SERVER + "/road/lictran/licApp/getCurrentLink")
                .params("REQ_NO", req_no)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        ApprovalBean approvalBean = JSON.parseObject(response.body(),ApprovalBean.class);
                        if (mView == null)
                            return;
                        if (approvalBean.getCode().equals("0000")){
                            mView.getLinks(approvalBean);
                        }else {
                            mView.onRequestError(approvalBean.getMessage());
                        }
                    }
                });
    }
    @Override
    public void getProces(String req_no) {
        OkGo.<String>get(Urls.SERVER + "/road/lictran/licApp/ks/getProcess")
                .params("req_no", req_no)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        ProcesBean procesBean = JSON.parseObject(response.body(),ProcesBean.class);
                        if (mView == null)
                            return;
                        if (procesBean.getCode().equals("0000")){
                            mView.getProcess(procesBean);
                        }else {
                            mView.onRequestError(procesBean.getMessage());
                        }
                    }
                });
    }
    @Override
    public void getGSProces(String req_no) {
        OkGo.<String>get(Urls.SERVER + "/road/lictran/licApp/sn/getProcess")
                .params("req_no", req_no)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        GSProcesBean gsProcesBean = JSON.parseObject(response.body(),GSProcesBean.class);
                        if (mView == null)
                            return;
                        if (gsProcesBean.getCode().equals("0000")){
                            mView.getGSProces(gsProcesBean);
                        }else {
                            mView.onRequestError(gsProcesBean.getMessage());
                        }
                    }
                });
    }
}
